{% form_theme form '::fields2tab.html.twig' %}
<div class="contentwrapper">
    <div class="heading">
        <h3>Modifier Famille Article</h3>
    </div>
    <div class="row-fluid">
        <div class="span12">
            <form id="form_famille" action="" {{ form_enctype(form) }} method="POST" class="form-horizontal seperator">
                {{ form_row(form.libelle) }}
                    {{ form_row(form.famille_mere) }}
                    {{ form_row(form._token) }}
                    <div style="float: left;width: 90%" class="form-actions">
                        <button onclick="saveFamille()" class="btn btn-info" type="button">Enregistrer et retour vers liste</button>
                        <button onclick="listFamille()" class="btn" type="button">Retour vers liste</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script>
        $('#gds_articlebundle_familletype_famille_mere option').each(function(){
            if($(this).val() == '{{id}}')
            $(this).remove()
        })

                            function saveFamille() {
                                var data = $('#form_famille').serialize()
                                if ($('#form_famille').valid()) {
                                    $.ajax({
                                        type: 'post',
                                        url: '{{ path('gds_famille_article_edit') }}',
                                        data: data + '&id={{id}}',
                                        success: function(data) {
                                            $('#div_famille').html(data)
                                        }
                                    })
                                }
                            }
                            function listFamille() {
                                $.ajax({
                                    type: 'post',
                                    url: '{{ path('gds_famille_article_list') }}',
                                    success: function(data) {
                                        $('#div_famille').html(data)
                                    }
                                })
                            }
        </script>